﻿using Microsoft.AspNetCore.Mvc;
using SmartAnswerPlatform.IService.System;
using SmartAnswerPlatform.Models.RequestModels;
using SmartAnswerPlatform.Models.ViewModels.System;

namespace SmartAnswerPlatform.WebApi.Controllers.System
{
    [Route("menu")]
    public class SysMenuController : BaseController
    {
        private readonly ISysMenuService _sysMenuService;

        public SysMenuController(ISysMenuService sysMenuService)
        {
            _sysMenuService = sysMenuService;
        }

        [HttpPost("findAll")]
        public async Task<ActionResult> FindAll()
        {
            return Success(await _sysMenuService.FindAll());
        }

        [HttpPost("add")]
        public async Task<ActionResult> Add([FromBody] SysMenuViewModel menuViewModel)
        {
            return Success(await _sysMenuService.Insert(menuViewModel));
        }

        [HttpPost("update")]
        public async Task<ActionResult> update([FromBody] SysMenuViewModel menuViewModel)
        {
            return Success(await _sysMenuService.Update(menuViewModel));
        }

        [HttpPost("delete")]
        public async Task<ActionResult> delete([FromBody] IdRequestModels idRequest)
        {
            return Success(await _sysMenuService.Delete(idRequest.Id));
        }
    }
}
